import 'package:boss/color_constant.dart';
import 'package:boss/models/takeout_business.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/image/base_image.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class BusinessSettingHeader extends StatelessWidget {
  final TakeoutBusiness data;
  final VoidCallback onTimeTap;

  const BusinessSettingHeader({this.data, this.onTimeTap});


  //结束时间小于开始时间 显示提示文字 次日
  String tomorrowTipsTitle(){
    if(data?.takeoutBusinessHours==null){
        return '';
    }
    String _today=DateTime.now().toString().substring(0,10)+' ';
    String newStartTime=_today+data.takeoutBusinessHours.split("-")[0]+':00';
    String newEndTime=_today+data.takeoutBusinessHours.split("-")[1]+':00';

    var res=DateTime.parse(newStartTime).compareTo(DateTime.parse(newEndTime));

    if(res>-1){
      return '次日';
    }

    return "";

  }


  @override
  Widget build(BuildContext context) {
    return ShadowRadiusCard(
      padding: EdgeInsets.symmetric(
        vertical: 30.w,
        horizontal: 20.w,
      ),
      margin: EdgeInsets.only(
        top: 30.w,
        bottom: 10.w,
      ),
      child: GestureDetector(
        onTap: onTimeTap,
        child: Column(
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text(
                  "营业时间",
                  style: TextStyleConstant().normal_1_28,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      "修改",
                      style: TextStyleConstant().normal_3_28,
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 10.w),
                      child: BaseImage(
                        'assets/image/arrow_right_icon_grey.png',
                        width: 13.w,
                        height: 30.w,
                      ),
                    ),
                  ],
                )
              ],
            ),
            Container(
              margin: EdgeInsets.only(top: 30.w),
              child: Column(
                children: <Widget>[

                  Text(
                    "${'${data.startHourMinute}' + '-' + '${tomorrowTipsTitle()}${data.endHourMinute}'}",
                    style: TextStyle(
                      fontSize: 50.sp,
                      color: ColorConstant.ff33,
                      fontFamily: 'DINAlternate-Bold',
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(
                      top: 20.w,
                      bottom: 16.w,
                    ),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Text(
                          "营业",
                          style: TextStyleConstant().normal_2_28,
                        ),
                        SizedBox(
                          width: 80.w,
                        ),
                        Text(
                          "休息",
                          style: TextStyleConstant().normal_2_28,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
